package routes

import (
	"fmt"
	"jwgin/server/company"
	v1 "jwgin/server/v1"

	//"github.com/gin-contrib/pprof"
	"github.com/gin-gonic/gin"
	"jwgin/middleware"
	"jwgin/server/admin"
	"jwgin/server/ts"
	"jwgin/service"
)

func InitWebRoute() error {
	g := service.Conf.System
	gin.SetMode(g.Env)
	r := gin.New()
	//pprof.Register(r)

	r.Use(middleware.Middlewares()...)

	rt := r.Group("")

	//test
	new(ts.BaseRouter).InitBaseRouter(rt)

	//前端
	new(v1.BaseRouter).InitBaseRouter(rt)
	//后台
	new(admin.BaseRouter).InitBaseRouter(rt)

	//客户管理后台
	new(company.BaseRouter).InitBaseRouter(rt)

	return r.Run(fmt.Sprintf(":%v", g.Addr))

}
